







//
//  SHTradingDateControl.m
//  JiFengDaRen
//
//  Created by SH_iOS on 2017/10/23.
//  Copyright © 2017年 SH_iOS. All rights reserved.
//
#import "SHTradingDateControl.h"
@interface SHTradingDateControl()


@end
@implementation SHTradingDateControl

- (instancetype)initWithFrame:(CGRect)frame{
    
    if (self =  [super initWithFrame:frame])
    {
        self.backgroundColor = [UIColor whiteColor];
        [self.leftImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(@(__I6Width(29)));
            make.top.mas_equalTo(@(__I6Height(22)));
            make.width.mas_equalTo(@(22));
            make.height.mas_equalTo(@(12));

        }];
        
        [self.rightTradingDateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.leftImg.mas_right).with.offset(__I6Width(22));
            make.centerY.equalTo(self.leftImg);

        }];
        
        [self.tradingDateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.leftImg);
        make.top.mas_equalTo(self.rightTradingDateLabel.mas_bottom).with.offset(__I6Height(14));
        }];
        
    }
    
    return self;

}

- (UIImageView *)leftImg{
    
    if(!_leftImg){
        
        _leftImg = [[UIImageView alloc]init];
        _leftImg.image = [UIImage imageNamed:@"shtradingqueryDate"];
        _leftImg.contentMode = UIViewContentModeScaleAspectFit;
        [self addSubview:_leftImg];
    }
    return _leftImg;
}
- (SHLabel *)rightTradingDateLabel{
    
    if (!_rightTradingDateLabel) {
        _rightTradingDateLabel = [SHLabel labelWithText:@"" font:13 textColor:[UIColor colorWithHexString:@"#999999"] textAlignment:NSTextAlignmentCenter];
        [self addSubview:_rightTradingDateLabel];
    }
    
    return _rightTradingDateLabel;
}
- (SHLabel *)tradingDateLabel{
    
    if (!_tradingDateLabel) {
        _tradingDateLabel = [SHLabel labelWithText:@"" font:17 textColor:[UIColor colorWithHexString:@"#333333"] textAlignment:NSTextAlignmentCenter];
        [self addSubview:_tradingDateLabel];
    }
    
    return _tradingDateLabel;
    
    
}
-  (void)setTradingDateName:(NSString *)tradingDateName{
    
    _rightTradingDateLabel.text  = tradingDateName;
    
}

-  (void)setTradingDate:(NSString *)tradingDate{
    _tradingDateLabel.text  = tradingDate;

}

#pragma mark - 更新自控制的约束
- (void)updateSubViewsConstraints{
    
   
    
    [self.rightTradingDateLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
    make.right.mas_equalTo(self.mas_right).with.offset(__I6Width(-30));
        make.top.mas_equalTo(@(__I6Height(22)));

    }];
    
   
    
    [self.leftImg mas_remakeConstraints:^(MASConstraintMaker *make) {
       make.right.mas_equalTo(self.rightTradingDateLabel.mas_left).with.offset(__I6Width(-21));
        make.top.mas_equalTo(@(__I6Height(22)));
        make.width.mas_equalTo(@(22));
        make.height.mas_equalTo(@(12));
        
    }];
    
    [self.tradingDateLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.leftImg);
        make.top.mas_equalTo(self.rightTradingDateLabel.mas_bottom).with.offset(__I6Height(14));
    }];
    
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
